﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {

        if (!IsPostBack) {

            System.Configuration.ClientSettingsSection config =
                (System.Configuration.ClientSettingsSection) System.Configuration.ConfigurationManager.GetSection("applicationSettings/BadHabit.Factory.Properties.Settings");

      

            FactoryCompanyName.Text = config.Settings.Get("FactoryCompanyName").Value.ValueXml.InnerText;            
            FactoryEmailAccount.Text = config.Settings.Get("FactoryEmailAccount").Value.ValueXml.InnerText;  
            
            FactoryEmailAccount.NavigateUrl = "mailto: " + FactoryEmailAccount.Text;
            string serverName = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.ToLower().IndexOf("/default.aspx"));

            string clientLink = config.Settings.Get("ClientLaunchServerUrl").Value.ValueXml.InnerText + "?ServerUrl=" + serverName;

            if (Page.Request["adminAccessKey"] != null)
                clientLink = clientLink + "&adminAccessKey=" + Page.Request["adminAccessKey"];
            accessButton.NavigateUrl = clientLink;
            accessButton.Text = accessButton.NavigateUrl;

            Response.Write("<USER " + Page.User.Identity.Name +" />");
        }

    }
}
